<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/1/4
  Time: 14:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加用户</title>
    <style>

        .blue_text {
            width: 100px;
            background: rgb(112, 144, 183);
        }

        table, tr, td {
            border: 1px solid rgb(112, 144, 183);
            text-align: center;
        }

        td {
            padding: 9px;
        }

        table {
            margin: auto;
            margin-bottom: 100px;
            width: 650px;
        }

        .aaa {
            padding: 10px;
        }

        #username, #password {
            border: none;
            outline: none;
            border-bottom: 1px solid;

        }

        label span {
            width: 66px;
            display: inline-block;
            margin-bottom: 20px;
        }

        .main {
            border: 2px solid cornflowerblue;
        }
    </style>
</head>
<script src="${pageContext.request.contextPath}/js/jquery-3.5.1.min.js">

</script>
<body>
<div style="width: 760px">
    <%@ include file="../common/header.jsp" %>
    <div class="main">
        <div style="margin: 10px 20px">
            <img src="../img/user.gif" alt="用户管理">
        </div>
        <div style="text-align: center;font-size: 22px;color:rgb(112, 144, 183);margin-bottom: 20px">
            新增加一个管理者
        </div>

        <div>
            <div style="width: 266px;margin: auto">
                <form action="${pageContext.request.contextPath}/admin/add" method="post">
                    <div style="width: 400px">
                        <label for="username"> <span>用户名：</span><input id="username" type="text"
                                                                       name="username" required></label>
                        <span id="exist" style="color: red;display: none">用户名已经被注册</span>
                    </div>
                    <div>
                        <label for="password"><span> 密&nbsp&nbsp&nbsp码：</span><input id="password" type="password"
                                                                                     name="password" required></label>
                    </div>
                    <div style="width: 200px;margin: auto;margin-bottom: 20px">
                        <span>权限管理:</span>
                        <select name="role">
                            <option value="10">超级管理员</option>
                            <option value="20">普通管理员</option>
                        </select>
                    </div>

                    <div style="width: 130px;margin: auto;height: 33px">
                        <button>新增一个管理者</button>
                    </div>
                </form>
            </div>


        </div>


        <%@ include file="../common/footer.jsp" %>
    </div>
</body>
<script>
    $(function (e) {
        $("#username").blur(function () {
            var username = this.value
            $.post({
                url:"${pageContext.request.contextPath}/admin/reg",
                data:{
                    "username":username
                },
                success:function (obj) {
                    if (obj==="false"){
                        $("#exist").show()
                    }else {
                        $("#exist").hide()
                    }
                }
            })
        })
    })
</script>
</html>
